﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>存货档案选择</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <link href="~/Content/Scripts/layui/css/layui.css" rel="stylesheet" />
    @*<script src="~/Content/X-admin/lib/layui/layui.js"></script>*@
    @*<script src="~/Content/X-admin/lib/layui/lay/modules/tree.js"></script>*@
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/layui/layui.js"></script>


</head>
<body>
    <div class="layui-fluid">  @* style="margin:5px" *@
        <div style="float:left">
            <div id="treeNav" class="demo-tree demo-tree-box" style="width: 190px; height:90%; overflow: scroll;float:left;"></div>

        </div>
        <div style="float:left;width:75%;">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                        <div class="layui-inline layui-show-xs-block">

                            <input type="text" name="proCode" placeholder="存货编码" autocomplete="off" class="layui-input" id="userCode">
                        </div>
                        <div class="layui-inline layui-show-xs-block">

                            <input type="text" name="proName" placeholder="存货名称" autocomplete="off" class="layui-input" id="userName">
                        </div>
                        <div class="layui-inline layui-show-xs-block">

                            <input type="text" name="spec" placeholder="规格型号" autocomplete="off" class="layui-input" id="spec">
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-filter="sreach" id="userSearch" type="button" onclick="loadData('')"><i class="layui-icon">&#xe615;</i></button>

                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn" id="confirm" type="button" onclick="Confirm()"><i class="layui-icon">&#xe679;</i>确认选择</button>
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-hide" id="list" lay-filter="list"></table>
                </div>
            </div>


        </div>
    </div>
</body>

</html>

<script>
    var cData = new Array();
    function loadData(typeCode) {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
            , cols: [[ //标题栏
                   { type: 'checkbox' }
                , { field: 'proCode', align: 'center', title: '存货编码', width: '16%' }
                , { field: 'proName', align: 'center', title: '存货名称', width: '35%' }
                , { field: 'spec', align: 'center', title: '规格', width: '14%'  }
                , { field: 'mUnit', align: 'center',title: '主计量单位', width: '13%'  }
                , { field: 'mUnitName', align: 'center', title: '主计量单位', width: '13%'  }
                , { field: 'cUnitName', align: 'center',title: '辅计量单位', width: '13%'  }
            ]], done: function (res, curr, count) {
                $("[data-field='mUnit']").css('display', 'none');//隐藏列
            }
            , url: "../Basis/GetDataList?condition=" + conditon + "&dataType=ven&typesCode=" + typeCode
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , limits: [20, 35, 50]
            , limit: 20 //每页默认显示的数量
            });
  
            //监听工具条
            /**
            table.on('radio(list)', function (obj) {
                var data = obj.data;
                //为父窗口input赋值
                cData=data;
                //$("#sname").val(data.proName);
 
            });**/
            //监听工具条
            table.on('checkbox(list)', function (obj) {
                var checkStatus = table.checkStatus('list');
                var select = new Array();
                for (var i = 0; i < checkStatus.data.length; i++) {
                    select.push(checkStatus.data[i]);
                  
                }
                cData = select;
            });
        });
    }
    var single = "1";
    $(function () {
        single = getUrlVariable("isSingle");
        $.ajax({
            url: "../Basis/venClassNavigation",
            dataType: "json",
            type: "POST",
            success: function (data) {
                if (data.Result) {
                    loadTree(data.Data);
                } else {
                    layer.msg(data.Message);
                }
            }
        });
    })
    /**
    存货大类树
    **/
    function loadTree(data) {
        layui.use('tree', function () {
            var tree = layui.tree;
            var layer = layui.layer;
            var util = layui.util;
            //开启节点操作图标
            tree.render({
                elem: '#treeNav'
                , data: data
                , click: function (obj) {
                    loadData(obj.data["id"]);
                }
            });
        });
    }
    /**
    确认选择
    **/
    function Confirm() {
        if (cData.length < 1) {
            layer.msg("您没有选择任何数据"); return;
        } else {
            if (single == "1" && cData.length > 1) {
                layer.msg("请选择一条数据"); return;
            } else {
                parent.getChildPar(cData); //这是父页面函数
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        }
    }
</script>

